import { AuthItem, Role } from 'src/global-type';

// TODO: 扩展权限
export const ADMINAUTH = {
  systemUser: [
    AuthItem.READ,
    AuthItem.MODIFY,
    AuthItem.CREATE,
    AuthItem.DELETE,
  ],
  systemLog: [AuthItem.READ, AuthItem.DELETE],
  model: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
  shader: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
  effects: [
    AuthItem.READ,
    AuthItem.MODIFY,
    AuthItem.CREATE,
    AuthItem.DELETE,
  ],
  game: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
  tool: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
};

export const ENTERPRISEAUTH = {
  systemUser: [
    AuthItem.READ,
    // AuthItem.MODIFY,
    // AuthItem.CREATE,
    // AuthItem.DELETE,
  ],
  systemLog: [AuthItem.READ, AuthItem.DELETE],
  model: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
  shader: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],

  effects: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
  game: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
  tool: [AuthItem.READ, AuthItem.MODIFY, AuthItem.CREATE, AuthItem.DELETE],
};

export const STAFFAUTH = {
  systemUser: [],
  systemLog: [AuthItem.READ],
  model: [AuthItem.READ],
  shader: [AuthItem.READ],
  effects: [AuthItem.READ],
  game: [AuthItem.READ],
  tool: [AuthItem.READ],
};

export const NONEAUTH = {
  systemUser: [],
  systemLog: [],
  model: [],
  shader: [],
  effects: [],
  game: [],
  tool: []
};

export const getCurrAuth = (role: Role, userId?: string) => {
  switch (role) {
    case Role.ADMIN:
      return userId ? { ...ADMINAUTH, userId } : ADMINAUTH;
    case Role.ENTERPRISE:
      return userId ? { ...ENTERPRISEAUTH, userId } : ENTERPRISEAUTH;
    case Role.STAFF:
      return userId ? { ...STAFFAUTH, userId } : STAFFAUTH;
    default:
      return userId ? { ...NONEAUTH, userId } : NONEAUTH;
  }
};
